package adapter;

import java.util.ArrayList;
import java.util.List;


import emergency.Emergency;

import unit.Ambulance;
import unit.FireTruck;
import unit.Garage;
import unit.PoliceCar;
import unit.Unit;

import be.kuleuven.cs.swop.api.*;

public class AUnitConfiguration implements be.kuleuven.cs.swop.api.IUnitConfiguration {
	
	private Emergency em;
	private ArrayList<Unit> suggestie;
	
	public AUnitConfiguration(Emergency em, Garage g){
		this.em = em;
		suggestie = em.getSuggestion(g);
	}

	@Override
	public List<IUnit> getAllUnits() {
		List<IUnit> unitList = new ArrayList<IUnit>();
		for(Unit u : suggestie){
			unitList.add(new AUnit(u));
		}
		return unitList;
	}

	public Emergency getEm() {
		return em;
	}

	@Override
	public AEmergency getEmergency() {
		return new AEmergency(em);
	}

	@Override
	public List<IAmbulanceView> getListOfAmbulances() {
		List<IAmbulanceView> unitList = new ArrayList<IAmbulanceView>();
		for(Unit u : suggestie){
			if(u instanceof Ambulance)
				unitList.add(new AAmbulanceView((Ambulance)u));
		}
		return unitList;
	}

	@Override
	public List<IFireTruckView> getListOfFireTrucks() {
		List<IFireTruckView> unitList = new ArrayList<IFireTruckView>();
		for(Unit u : suggestie){
			if(u instanceof FireTruck)
				unitList.add(new AFireTruckView((FireTruck)u));
		}
		return unitList;
	}

	@Override
	public List<IPoliceCarView> getListOfPoliceCars() {
		List<IPoliceCarView> unitList = new ArrayList<IPoliceCarView>();
		for(Unit u : suggestie){
			if(u instanceof PoliceCar)
				unitList.add(new APoliceCarView((PoliceCar)u));
		}
		return unitList;
	}

	public ArrayList<Unit> getSuggestie() {
		return suggestie;
	}

	

}
